package cn.wolfcode.trip.app.web.controller;

import cn.wolfcode.trip.base.domain.Tour;
import cn.wolfcode.trip.base.query.TourObject;
import cn.wolfcode.trip.base.service.ITourService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/tour")
public class TourController {

    @Autowired
    private ITourService service;


    //游记的评论添加
    @PostMapping
    @ResponseBody
    public Object saveTravelComment(Tour tour) {
        //保存完返回这个
        JSONResult result = new JSONResult();

        Long dealid = service.saveTour(tour);
        result.setData(dealid);
        return result;
    }


    @PostMapping("/read")
    @ResponseBody
    public Object pay(Long id) {
        JSONResult jsonResult = new JSONResult();
        service.changeState(id);
        return jsonResult;
    }


    //展示某一个用户的所有未出行的订单
    @GetMapping("/listAll")
    @ResponseBody
    public Object listAll(TourObject qo) {
        PageInfo info = service.query(qo);
        return info;
    }


}
